package up_down_share.viewcontroller.coverviewpager;

import java.util.ArrayList;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;





public class FPagerAdapter extends FragmentPagerAdapter
{

	// --------------------------------------------------
	// ----- constants -----
	// --------------------------------------------------

	// --------------------------------------------------
	// ----- properties -----
	// --------------------------------------------------
	private Context context = null;
	private final ArrayList<Class<?>> fragmentClass = new ArrayList<Class<?>>();

	// --------------------------------------------------
	// ----- extends -----
	// --------------------------------------------------

	public FPagerAdapter(final FragmentActivity activity)
	{
		super(activity.getSupportFragmentManager());
		context = activity;
	}

	@Override
	public Fragment getItem(final int arg0)
	{
		// TODO Auto-generated method stub
		// return Fragment.instantiate(mContext, page.clss.getName(), page.args);
		return Fragment.instantiate(context, fragmentClass.get(arg0).getName(), null);
	}

	@Override
	public int getCount()
	{
		// TODO Auto-generated method stub
		return fragmentClass.size();
	}

	// --------------------------------------------------
	// ----- functions -----
	// --------------------------------------------------
	public void addFragment(final Class<?> clss)
	{
		fragmentClass.add(clss);
		notifyDataSetChanged();
	}

}
